import 'package:flutter_admin/utils/utils.dart';

class SaleBidResult {
  String? id;
  String? projectId;
  String? biddate;
  num? projectbudget;
  String? bidmanufactor;
  num? bidamount;
  num? bidshare;
  num? discountfactor;
  num? bidresult;
  String? remark;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? priceScoring;
  num? ourQuotation;
  num? blankPrice;
  num? highestPrice;
  num? minimumPrice;

  SaleBidResult({
    this.id,
    this.projectId,
    this.biddate,
    this.projectbudget,
    this.bidmanufactor,
    this.bidamount,
    this.bidshare,
    this.discountfactor,
    this.bidresult,
    this.remark,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.priceScoring,
    this.ourQuotation,
    this.blankPrice,
    this.highestPrice,
    this.minimumPrice,
  });

  SaleBidResult copyWith({
    String? id,
    String? projectId,
    String? biddate,
    num? projectbudget,
    String? bidmanufactor,
    num? bidamount,
    num? bidshare,
    num? discountfactor,
    num? bidresult,
    String? remark,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
    String? priceScoring,
    num? ourQuotation,
    num? blankPrice,
    num? highestPrice,
    num? minimumPrice,
  }) {
    return new SaleBidResult(
      id: id ?? this.id,
      projectId: projectId ?? this.projectId,
      biddate: biddate ?? this.biddate,
      projectbudget: projectbudget ?? this.projectbudget,
      bidmanufactor: bidmanufactor ?? this.bidmanufactor,
      bidamount: bidamount ?? this.bidamount,
      bidshare: bidshare ?? this.bidshare,
      discountfactor: discountfactor ?? this.discountfactor,
      bidresult: bidresult ?? this.bidresult,
      remark: remark ?? this.remark,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
      priceScoring: priceScoring ?? this.priceScoring,
      ourQuotation: ourQuotation ?? this.ourQuotation,
      blankPrice: blankPrice ?? this.blankPrice,
      highestPrice: highestPrice ?? this.highestPrice,
      minimumPrice: minimumPrice ?? this.minimumPrice,
    );
  }

  @override
  String toString() {
    return '''SaleBidResult{
      id: $id,
      projectId: $projectId,
      biddate: $biddate,
      projectbudget: $projectbudget,
      bidmanufactor: $bidmanufactor,
      bidamount: $bidamount,
      bidshare: $bidshare,
      discountfactor: $discountfactor,
      bidresult: $bidresult,
      remark: $remark,
      createUid: $createUid,
      createDate: $createDate,
      writeUid: $writeUid,
      writeDate: $writeDate,
      priceScoring: $priceScoring,
      ourQuotation: $ourQuotation,
      blankPrice: $blankPrice,
      highestPrice: $highestPrice,
      minimumPrice: $minimumPrice,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is SaleBidResult &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          projectId == other.projectId &&
          biddate == other.biddate &&
          projectbudget == other.projectbudget &&
          bidmanufactor == other.bidmanufactor &&
          bidamount == other.bidamount &&
          bidshare == other.bidshare &&
          discountfactor == other.discountfactor &&
          bidresult == other.bidresult &&
          remark == other.remark &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate &&
          priceScoring == other.priceScoring &&
          ourQuotation == other.ourQuotation &&
          blankPrice == other.blankPrice &&
          highestPrice == other.highestPrice &&
          minimumPrice == other.minimumPrice);

  factory SaleBidResult.fromMap(Map<String, dynamic> map) {
    return new SaleBidResult(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      // projectId: map['project_id'] != false ? map['project_id'] : null,
      projectId: map['project_id'] != false
          ? map['project_id'][0].toString() as String?
          : "",
      biddate: map['biddate'] != false
          ? map['biddate'].toString().substring(0, 10) as String?
          : "",
      projectbudget:
          map['projectbudget'] != false ? map['projectbudget'] : null,
      bidmanufactor: map['bidmanufactor'] != false
          ? map['bidmanufactor'].toString() as String?
          : "",
      bidamount: map['bidamount'] != false ? map['bidamount'] : null,
      bidshare: map['bidshare'] != false ? map['bidshare'] : null,
      discountfactor:
          map['discountfactor'] != false ? map['discountfactor'] : null,
      bidresult: map['bidresult'] != false ? map['bidresult'] : null,
      remark: map['remark'] != false ? map['remark'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
      priceScoring: map['price_scoring'] != false
          ? map['price_scoring'].toString() as String?
          : "",
      ourQuotation: map['our_quotation'] != false ? map['our_quotation'] : null,
      blankPrice: map['blank_price'] != false ? map['blank_price'] : null,
      highestPrice: map['highest_price'] != false ? map['highest_price'] : null,
      minimumPrice: map['minimum_price'] != false ? map['minimum_price'] : null,
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'projectId': this.projectId,
      'biddate': this.biddate,
      'projectbudget': this.projectbudget,
      'bidmanufactor': this.bidmanufactor,
      'bidamount': this.bidamount,
      'bidshare': this.bidshare,
      'discountfactor': this.discountfactor,
      'bidresult': this.bidresult,
      'remark': this.remark,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
      'priceScoring': this.priceScoring,
      'ourQuotation': this.ourQuotation,
      'blankPrice': this.blankPrice,
      'highestPrice': this.highestPrice,
      'minimumPrice': this.minimumPrice,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.projectId != null && this.projectId != '')
        ['project_id', '=', int.parse(this.projectId!)],
    ] as List;
    //if(list.length==0){
    //  list.add(['id','!=',null]);
    //}
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'project_id': int.parse(this.projectId!),
      'biddate': this.biddate,
      'projectbudget': this.projectbudget,
      'bidmanufactor': this.bidmanufactor,
      'bidamount': this.bidamount,
      'bidshare': this.bidshare,
      'discountfactor': this.discountfactor,
      'bidresult': this.bidresult,
      'remark': this.remark,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
      'price_scoring': this.priceScoring,
      'our_quotation': this.ourQuotation,
      'blank_price': this.blankPrice,
      'highest_price': this.highestPrice,
      'minimum_price': this.minimumPrice,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
